package com.hksj.Intelligentmanagement.task;


import com.hksj.Intelligentmanagement.service.HqEnvironmentHistoryDataService;
import com.hksj.Intelligentmanagement.service.ReadHandNumbnessService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
@Slf4j
public class ReadHandNumbness {

    @Autowired
    private ReadHandNumbnessService service;

    @Autowired
    private HqEnvironmentHistoryDataService hqEnvironmentHistoryDataService;

    /**
     * 定时任务，每小时钟执行一次。
     */
    @Scheduled(cron = "0 0/30 * * * ?")
    @Transactional(rollbackFor = Exception.class)
    public void readHandNumbness() {
        service.startSync();
        log.info("开始执行定时任务");
    }

    @Scheduled(cron = "0 */3 * * * ?")
    public void autoSync(){
        hqEnvironmentHistoryDataService.autoSyncData();
    }
}
